package com.block.service.impl;

import com.block.common.Msg;
import com.block.dao.BlockUserMapper;
import com.block.dao.InterestBlockMapper;
import com.block.entity.BlockUser;
import com.block.entity.InterestBlock;
import com.block.service.InterestBlockService;
import jdk.nashorn.internal.ir.Block;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class InterestBlockImpl implements InterestBlockService {

    //部落块表....
    @Resource
    private InterestBlockMapper interestBlockMapper;
    //用户进入的部落表，记录用户进入的哪个部落
    @Resource
    private BlockUserMapper blockUserMapper;


    //查询所有部落板块，可根据条件过滤
    @Override
    public Msg getBlock(InterestBlock block) {
        Msg msg=new Msg();
        //Msg msg=new Msg();
        List<InterestBlock> list=interestBlockMapper.getBlock(block);
        if (list!=null){
            msg.setData(list);//把数据放入到容器中
        }else{
            msg.setMsg("空空如也⊙_⊙");
        }
        return msg;
    }
    //创建部落块
    @Override
    public Msg createBlock(InterestBlock block) {
        Msg msg=new Msg();
        if(interestBlockMapper.insertSelective(block)>0){
            msg.setMsg("创建成功≧∇≦");
        }else{
            msg.setCode(-1);
            msg.setMsg("创建失败，未知错误⊙_⊙");
        }
        return msg;
    }
    //修改部落基本信息
    @Override
    public Msg updateBlock(InterestBlock block) {
        Msg msg=new Msg();
        if(interestBlockMapper.insertSelective(block)>0){
            msg.setMsg("修改成功≧∇≦");
        }else{
            msg.setCode(-1);
            msg.setMsg("修改出错了⊙_⊙");
        }
        return msg;
    }
    //获取部落总贡献值

    //获取部落所有被关注人数,
    @Override
    public Msg getPeopleCount(InterestBlock block) {
        return null;
    }



}
